/** * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai * Project: Hilmacorp.ai — Web Platform * File: app/[locale]/layout.tsx * Description: Locale-scoped root layout — HTML shell, fonts, global metadata, header and footer */ import type { Metadata } from "next"; import { Inter, Fraunces } from "next/font/google"; import { notFound } from "next/navigation"; import Header from "@/components/Header"; import Footer from "@/components/Footer"; import CookieConsent from "@/components/CookieConsent"; import { getMessages, isLocale, locales, type Locale } from "@/lib/i18n"; import "@/app/globals.css"; const inter = Inter({ subsets: ["latin"], variable: "--font-inter", display: "swap" }); const fraunces = Fraunces({ subsets: ["latin"], variable: "--font-fraunces", display: "swap" }); const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL ?? "https://www.hilmacorp.ai"; export function generateStaticParams() { return locales.map((locale) => ({ locale })); } export async function generateMetadata({ params, }: { params: Promise<{ locale: string }>; }): Promise { const { locale } = await params; if (!isLocale(locale)) return {}; const messages = getMessages(locale); return { metadataBase: new URL(SITE_URL), title: { default: messages.meta.home.title, template: `%s — ${messages.meta.siteName}`, }, description: messages.meta.home.description, alternates: { languages: { fr: "/fr", en: "/en" }, }, openGraph: { type: "website", siteName: messages.meta.siteName, locale: locale === "fr" ? "fr_CA" : "en_US", url: `${SITE_URL}/${locale}`, title: messages.meta.home.title, description: messages.meta.home.description, }, twitter: { card: "summary", title: messages.meta.home.title, description: messages.meta.home.description, }, robots: { index: true, follow: true }, }; } export default async function LocaleLayout({ children, params, }: { children: React.ReactNode; params: Promise<{ locale: string }>; }) { const { locale } = await params; if (!isLocale(locale)) notFound(); const typedLocale = locale as Locale; const messages = getMessages(typedLocale); return (
{children}